package app.mkp.model;

import app.mkp.model.common.TandaTerimaFakturAM;
import app.mkp.model.view.ttf.createnew.MknTtfAddedDocViewImpl;
import app.mkp.model.view.ttf.createnew.MknTtfAddedDocViewRowImpl;
import app.mkp.model.view.ttf.createnew.MknTtfExistingDocViewImpl;

import app.mkp.model.view.ttf.createnew.MknTtfKontrakPlafonValidationImpl;
import app.mkp.model.view.ttf.createnew.MknTtfValidationViewImpl;
import app.mkp.model.view.ttf.createnew.MknTtfViewImpl;

import app.mkp.model.view.ttf.createnew.MknTtfViewRowImpl;

import app.mkp.model.view.ttf.linkdoc.MknDokLinkViewImpl;
import app.mkp.model.view.ttf.linkdoc.MknDokLinkViewRowImpl;

import app.mkp.model.view.ttf.linkdoc.PreInitialDocumentViewImpl;

import java.math.BigInteger;

import oracle.jbo.Row;
import oracle.jbo.RowSetIterator;
import oracle.jbo.domain.Number;
import oracle.jbo.server.ApplicationModuleImpl;
import oracle.jbo.server.ViewLinkImpl;
import oracle.jbo.server.ViewObjectImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Fri Oct 11 13:40:04 ICT 2013
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class TandaTerimaFakturAMImpl extends ApplicationModuleImpl implements TandaTerimaFakturAM {
    /**
     * This is the default constructor (do not remove).
     */
    public TandaTerimaFakturAMImpl() {
    }

    /**
     * Container's getter for InitialDocumentTtfView1.
     * @return InitialDocumentTtfView1
     */
    public ViewObjectImpl getInitialDocumentTtfView1() {
        return (ViewObjectImpl)findViewObject("InitialDocumentTtfView1");
    }

    /**
     * Container's getter for MknTtfSearchingView1.
     * @return MknTtfSearchingView1
     */
    public ViewObjectImpl getMknTtfSearchingView1() {
        return (ViewObjectImpl)findViewObject("MknTtfSearchingView1");
    }

    /**
     * Container's getter for PreInitialDocumentView1.
     * @return PreInitialDocumentView1
     */
    public ViewObjectImpl getPreInitialDocumentView1() {
        return (ViewObjectImpl)findViewObject("PreInitialDocumentView1");
    }


    /**
     * Container's getter for InvoiceView1.
     * @return InvoiceView1
     */
    public ViewObjectImpl getInvoiceView1() {
        return (ViewObjectImpl)findViewObject("InvoiceView1");
    }

    /**
     * Container's getter for MknTtfReviewView1.
     * @return MknTtfReviewView1
     */
    public ViewObjectImpl getMknTtfReviewView1() {
        return (ViewObjectImpl)findViewObject("MknTtfReviewView1");
    }

    /**
     * Container's getter for MknTtfReqDocView1.
     * @return MknTtfReqDocView1
     */
    public ViewObjectImpl getMknTtfReqDocView1() {
        return (ViewObjectImpl)findViewObject("MknTtfReqDocView1");
    }

    /**
     * Container's getter for MknTtfAddedDocView1.
     * @return MknTtfAddedDocView1
     */
    public ViewObjectImpl getMknTtfAddedDocView1() {
        return (ViewObjectImpl)findViewObject("MknTtfAddedDocView1");
    }

    /**
     * Container's getter for MknTtfView1.
     * @return MknTtfView1
     */
    public ViewObjectImpl getMknTtfView1() {
        return (ViewObjectImpl)findViewObject("MknTtfView1");
    }

    /**
     * Container's getter for MknTtfAddedDocView2.
     * @return MknTtfAddedDocView2
     */
    public ViewObjectImpl getMknTtfAddedDocView2() {
        return (ViewObjectImpl)findViewObject("MknTtfAddedDocView2");
    }

    /**
     * Container's getter for MknTtfReqDocView2.
     * @return MknTtfReqDocView2
     */
    public ViewObjectImpl getMknTtfReqDocView2() {
        return (ViewObjectImpl)findViewObject("MknTtfReqDocView2");
    }

    /**
     * Container's getter for UtilizationKontrakView1.
     * @return UtilizationKontrakView1
     */
    public ViewObjectImpl getUtilizationKontrakView1() {
        return (ViewObjectImpl)findViewObject("UtilizationKontrakView1");
    }

    /**
     * Container's getter for TtfMonitoringView1.
     * @return TtfMonitoringView1
     */
    public ViewObjectImpl getTtfMonitoringView1() {
        return (ViewObjectImpl)findViewObject("TtfMonitoringView1");
    }

    /**
     * Container's getter for TtfMonitoringDetail1.
     * @return TtfMonitoringDetail1
     */
    public ViewObjectImpl getTtfMonitoringDetail1() {
        return (ViewObjectImpl)findViewObject("TtfMonitoringDetail1");
    }

    /**
     * Container's getter for MknMyTtfView1.
     * @return MknMyTtfView1
     */
    public ViewObjectImpl getMknMyTtfView1() {
        return (ViewObjectImpl)findViewObject("MknMyTtfView1");
    }

    /**
     * Container's getter for MknMyTtfAddedDocView1.
     * @return MknMyTtfAddedDocView1
     */
    public ViewObjectImpl getMknMyTtfAddedDocView1() {
        return (ViewObjectImpl)findViewObject("MknMyTtfAddedDocView1");
    }

    /**
     * Container's getter for MknTtfExistingDocView1.
     * @return MknTtfExistingDocView1
     */
    public MknTtfExistingDocViewImpl getMknTtfExistingDocView1() {
        return (MknTtfExistingDocViewImpl)findViewObject("MknTtfExistingDocView1");
    }


    /**
     * Container's getter for InitialDocumentInvoiceViewLink1.
     * @return InitialDocumentInvoiceViewLink1
     */
    public ViewLinkImpl getInitialDocumentInvoiceViewLink1() {
        return (ViewLinkImpl)findViewLink("InitialDocumentInvoiceViewLink1");
    }

    /**
     * Container's getter for InvoiceMknTtfReviewViewLink1.
     * @return InvoiceMknTtfReviewViewLink1
     */
    public ViewLinkImpl getInvoiceMknTtfReviewViewLink1() {
        return (ViewLinkImpl)findViewLink("InvoiceMknTtfReviewViewLink1");
    }

    /**
     * Container's getter for MknTtfReviewReqDocViewLink1.
     * @return MknTtfReviewReqDocViewLink1
     */
    public ViewLinkImpl getMknTtfReviewReqDocViewLink1() {
        return (ViewLinkImpl)findViewLink("MknTtfReviewReqDocViewLink1");
    }

    /**
     * Container's getter for MknTtfReviewAddedDocViewLink1.
     * @return MknTtfReviewAddedDocViewLink1
     */
    public ViewLinkImpl getMknTtfReviewAddedDocViewLink1() {
        return (ViewLinkImpl)findViewLink("MknTtfReviewAddedDocViewLink1");
    }

    /**
     * Container's getter for InvoiceMknTtfViewLink1.
     * @return InvoiceMknTtfViewLink1
     */
    public ViewLinkImpl getInvoiceMknTtfViewLink1() {
        return (ViewLinkImpl)findViewLink("InvoiceMknTtfViewLink1");
    }

    /**
     * Container's getter for MknTtfAddedDocViewLink1.
     * @return MknTtfAddedDocViewLink1
     */
    public ViewLinkImpl getMknTtfAddedDocViewLink1() {
        return (ViewLinkImpl)findViewLink("MknTtfAddedDocViewLink1");
    }

    /**
     * Container's getter for MknTtfReqDocViewLink1.
     * @return MknTtfReqDocViewLink1
     */
    public ViewLinkImpl getMknTtfReqDocViewLink1() {
        return (ViewLinkImpl)findViewLink("MknTtfReqDocViewLink1");
    }

    /**
     * Container's getter for TtfMonitoringDetailViewLink1.
     * @return TtfMonitoringDetailViewLink1
     */
    public ViewLinkImpl getTtfMonitoringDetailViewLink1() {
        return (ViewLinkImpl)findViewLink("TtfMonitoringDetailViewLink1");
    }

    /**
     * Container's getter for MknMyTtfAddedDocViewLink1.
     * @return MknMyTtfAddedDocViewLink1
     */
    public ViewLinkImpl getMknMyTtfAddedDocViewLink1() {
        return (ViewLinkImpl)findViewLink("MknMyTtfAddedDocViewLink1");
    }

    /**
     * Generate existing doc to added doc table
     */
    public void generateExistingDoc(String dId) {

        // Get Parent Key
        MknTtfViewImpl mknTtfView = (MknTtfViewImpl)this.getMknTtfView1();
        MknTtfViewRowImpl masterViewRow =
            (MknTtfViewRowImpl)mknTtfView.getCurrentRow();
        masterViewRow.getKey();

        MknTtfAddedDocViewImpl addedDocView =
            (MknTtfAddedDocViewImpl)this.getMknTtfAddedDocView2();

        // Fetch Existing Doc
        MknTtfExistingDocViewImpl existingDoc =
            this.getMknTtfExistingDocView1();
        existingDoc.setinvDid(dId);
        existingDoc.executeQuery();

        RowSetIterator existingDocIter = existingDoc.getRowSetIterator();

        while (existingDocIter.hasNext()) {
            Row existingDocRow = existingDocIter.next();
            /*
            System.out.println("----------------------------------");
            System.out.println("EXISTING DOC DID: " +
                               existingDocRow.getAttribute("Did"));
            System.out.println("----------------------------------");
            */
            // Add existing doc to added doc
            MknTtfAddedDocViewRowImpl addedDocRow =
                (MknTtfAddedDocViewRowImpl)addedDocView.createRow();
            addedDocRow.setDid((oracle.jbo.domain.Number)existingDocRow.getAttribute("Did"));
            addedDocView.insertRow(addedDocRow);

        }
    }

    /**
     * Container's getter for TtfMonitoringByDeptView1.
     * @return TtfMonitoringByDeptView1
     */
    public ViewObjectImpl getTtfMonitoringByDeptView1() {
        return (ViewObjectImpl)findViewObject("TtfMonitoringByDeptView1");
    }

    /**
     * Container's getter for TtfMonitoringDetail2.
     * @return TtfMonitoringDetail2
     */
    public ViewObjectImpl getTtfMonitoringDetail2() {
        return (ViewObjectImpl)findViewObject("TtfMonitoringDetail2");
    }

    /**
     * Container's getter for TtfMonitoringByDeptDetailViewLink1.
     * @return TtfMonitoringByDeptDetailViewLink1
     */
    public ViewLinkImpl getTtfMonitoringByDeptDetailViewLink1() {
        return (ViewLinkImpl)findViewLink("TtfMonitoringByDeptDetailViewLink1");
    }

    /**
     * Container's getter for MknTtfValidationView1.
     * @return MknTtfValidationView1
     */
    public MknTtfValidationViewImpl getMknTtfValidationView1() {
        return (MknTtfValidationViewImpl)findViewObject("MknTtfValidationView1");
    }

    /**
     * Container's getter for LovDocument1.
     * @return LovDocument1
     */
    public ViewObjectImpl getLovDocument1() {
        return (ViewObjectImpl)findViewObject("LovDocument1");
    }

    /**
     * Container's getter for MknTtfReviewView2.
     * @return MknTtfReviewView2
     */
    public ViewObjectImpl getMknTtfReviewView2() {
        return (ViewObjectImpl)findViewObject("MknTtfReviewView2");
    }

    /**
     * Container's getter for MknTtfAddedDocView3.
     * @return MknTtfAddedDocView3
     */
    public MknTtfAddedDocViewImpl getMknTtfAddedDocView3() {
        return (MknTtfAddedDocViewImpl)findViewObject("MknTtfAddedDocView3");
    }

    /**
     * Container's getter for MknTtfReviewAddedDocViewLink2.
     * @return MknTtfReviewAddedDocViewLink2
     */
    public ViewLinkImpl getMknTtfReviewAddedDocViewLink2() {
        return (ViewLinkImpl)findViewLink("MknTtfReviewAddedDocViewLink2");
    }

    /**
     * Container's getter for MknTtfReqDocView3.
     * @return MknTtfReqDocView3
     */
    public ViewObjectImpl getMknTtfReqDocView3() {
        return (ViewObjectImpl)findViewObject("MknTtfReqDocView3");
    }

    /**
     * Container's getter for MknTtfReviewReqDocViewLink2.
     * @return MknTtfReviewReqDocViewLink2
     */
    public ViewLinkImpl getMknTtfReviewReqDocViewLink2() {
        return (ViewLinkImpl)findViewLink("MknTtfReviewReqDocViewLink2");
    }


    /**
     * Container's getter for LovDocPoImKontrak1.
     * @return LovDocPoImKontrak1
     */
    public ViewObjectImpl getLovDocPoImKontrak1() {
        return (ViewObjectImpl)findViewObject("LovDocPoImKontrak1");
    }

     /**
      * Generate self doc to link doc table
      */
     public void generateSelfDoc(String dId, String tipeDok) {
         
         MknDokLinkViewImpl dokLinkView =
             this.getMknDokLinkView1();

         // Add self doc to link doc
         MknDokLinkViewRowImpl dokLinkRow =
             (MknDokLinkViewRowImpl)dokLinkView.createRow();
         dokLinkRow.setDid(Integer.valueOf(dId));
         dokLinkRow.setLinkDokDid(Integer.valueOf(dId));
         dokLinkRow.setNoParent("N");
         dokLinkRow.setTipeDok(tipeDok);
         dokLinkView.insertRow(dokLinkRow);
     }
     
    /**
     * Execute to get attached document
     */
    public void generateAttachDoc(String dId) {
        
        MknDokLinkViewImpl dokLinkView =
            this.getMknDokLinkView1();        
        dokLinkView.setWhereClauseParam(2, dId);
        dokLinkView.executeQuery();
    }

    /**
     * Container's getter for MknDokLinkView1.
     * @return MknDokLinkView1
     */
    public MknDokLinkViewImpl getMknDokLinkView1() {
        return (MknDokLinkViewImpl)findViewObject("MknDokLinkView1");
    }

    /**
     * Container's getter for PreInitialDocumentMknDokLinkViewLink1.
     * @return PreInitialDocumentMknDokLinkViewLink1
     */
    public ViewLinkImpl getPreInitialDocumentMknDokLinkViewLink1() {
        return (ViewLinkImpl)findViewLink("PreInitialDocumentMknDokLinkViewLink1");
    }

    /**
     * Container's getter for LovDocIm1.
     * @return LovDocIm1
     */
    public ViewObjectImpl getLovDocIm1() {
        return (ViewObjectImpl)findViewObject("LovDocIm1");
    }

    /**
     * Container's getter for LovDocPoIm1.
     * @return LovDocPoIm1
     */
    public ViewObjectImpl getLovDocPoIm1() {
        return (ViewObjectImpl)findViewObject("LovDocPoIm1");
    }

    /**
     * Container's getter for MknTtfKontrakPlafonValidation1.
     * @return MknTtfKontrakPlafonValidation1
     */
    public MknTtfKontrakPlafonValidationImpl getMknTtfKontrakPlafonValidation1() {
        return (MknTtfKontrakPlafonValidationImpl)findViewObject("MknTtfKontrakPlafonValidation1");
    }
}
